home *** CD-ROM | disk | FTP | other *** search
- ;;;; ----------------------------------------------------------------------
- ;;;; PURPOSE: drag&drop send routine for "XXX" data
- ;;;;
- ;;;; Widgets that are to participate in drag&drop operations for
- ;;;; "XXX" data should be registered as follows:
- ;;;;
- ;;;; (blt_drag&drop .win 'source 'handler 'XXX 'dd-send-color)
- ;;;; (blt_drag&drop .win 'target 'handler 'XXX 'my-color-handler)
- ;;;;
- ;;;; (define (my-color-handler)
- ;;;; (let ((data (hash-table-get DragDrop 'XXX ;;;;f)))
- ;;;; (if data
- ;;;; .
- ;;;; . do something with $data
- ;;;; .
- ;;;; )))
- ;;;; ORIGINAL AUTHOR: Michael J. McLennan Phone: (215)770-2842
- ;;;; AT&T Bell Laboratories E-mail: aluxpo!mmc@att.com
- ;;;;
- ;;;; ----------------------------------------------------------------------
- ;;;; Copyright (c) 1993 AT&T All Rights Reserved
- ;;;; ======================================================================
-
- ;;;;
- ;;;; rewritten for STk by Erick Gallesio [eg@unice.fr]
- ;;;; Creation date: 7-Jul-1994 10:13
- ;;;; Last file update: 12-Jul-1994 11:41
-
- (require "hash")
-
- (define DragDrop (make-hash-table))
-
- (define (make-drag&drop-label win . args)
- (let* ((token-name (& win ".label")))
- ;; If this window already exists, don't create it
- (when (= (winfo 'exists token-name) 0)
- (pack (label token-name)))
- ;; Now configure it to the given arguments
- (apply (string->widget token-name) 'configure args)))
-
- ;;;; ----------------------------------------------------------------------
- ;;;; (dd-send-color <interp> <ddwin> <data>)
- ;;;;
- ;;;; INPUTS
- ;;;; <interp> = interpreter for target application
- ;;;; <ddwin> = pathname for target drag&drop window
- ;;;; <data> = data returned from -tokencmd
- ;;;;
- ;;;; RETURNS
- ;;;; ""
- ;;;;
- ;;;; SIDE-EFFECTS
- ;;;; Sends data to remote application DragDrop(color), and then
- ;;;; invokes the "color" handler for the drag&drop target.
- ;;;; ----------------------------------------------------------------------
- (define (dd-send-color interp ddwin data)
- (send interp `(begin
- ;; Verify it is a color
- (winfo 'rgb *root* ',data)
- (hash-table-put! DragDrop 'color ',data)))
- (send interp `(blt_drag&drop 'target ,ddwin 'handle 'color))
- "")
-
- ;;;; ----------------------------------------------------------------------
- ;;;; dd-send-number <interp> <ddwin> <data>
- ;;;;
- ;;;; INPUTS
- ;;;; <interp> = interpreter for target application
- ;;;; <ddwin> = pathname for target drag&drop window
- ;;;; <data> = data returned from -tokencmd
- ;;;;
- ;;;; RETURNS
- ;;;; ""
- ;;;;
- ;;;; SIDE-EFFECTS
- ;;;; Sends data to remote application DragDrop(number), and then
- ;;;; invokes the "number" handler for the drag&drop target.
- ;;;; ----------------------------------------------------------------------
- (define (dd-send-number interp ddwin data)
- (send interp `(let ((x (if (string? ,data) (string->number ,data) ,data)))
- (unless (number? x)
- (error "dd-send-number: nbad number: ~S." x))
- (hash-table-put! DragDrop 'number x)))
- (send interp `(blt_drag&drop 'target ,ddwin 'handle 'number))
- "")
-
- ;;;; ----------------------------------------------------------------------
- ;;;; (dd-send-text <interp> <ddwin> <data>)
- ;;;;
- ;;;; INPUTS
- ;;;; <interp> = interpreter for target application
- ;;;; <ddwin> = pathname for target drag&drop window
- ;;;; <data> = data returned from -tokencmd
- ;;;;
- ;;;; RETURNS
- ;;;; ""
- ;;;;
- ;;;; SIDE-EFFECTS
- ;;;; Sends data to remote application DragDrop(text), and then
- ;;;; invokes the "text" handler for the drag&drop target.
- ;;;; ----------------------------------------------------------------------
- (define (dd-send-text interp ddwin data)
- (send interp `(hash-table-put! DragDrop 'text ,data))
- (send interp `(blt_drag&drop 'target ,ddwin 'handle 'text))
- "")
-
- (provide "dd-protocol")
-